export function getAgeByIdCard(idCard) {
	const sexAndAge = {}
	//获取用户身份证号码
	const userCard = idCard

	//如果用户身份证号码为undefined则返回空
	if (!userCard) {
		return sexAndAge
	}

	// 获取出生日期
	const yearBirth = userCard.substring(6, 10)
	const monthBirth = userCard.substring(10, 12)
	const dayBirth = userCard.substring(12, 14)
	// 获取当前年月日并计算年龄
	const myDate = new Date()
	const monthNow = myDate.getMonth() + 1
	const dayNow = myDate.getDate()
	let age = myDate.getFullYear() - yearBirth

	if (monthNow < monthBirth || (monthNow == monthBirth && dayNow < dayBirth)) {
		age--
	}

	// 得到年龄
	sexAndAge.age = age

	return sexAndAge.age
}